package com.mt.roll.wms.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.params.StorageBoxCircInfoParam;
import com.mt.roll.wms.params.StorageBoxCircInfoQueryParam;
import com.mt.roll.wms.service.StorageBoxCircInfoService;
import com.mt.roll.wms.vo.StorageBoxCircInfoVo;
import com.mt.roll.wms.vo.StorageBoxVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

/**
 * @auther why
 * @date 2021/9/26 14:41
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "storage/box/circ/info")
@Slf4j
@Api(value = "当前库存存储箱信息", tags = "当前库存存储箱信息", hidden = false)
public class StorageBoxCircInfoController extends BaseController {


    @Autowired
    private StorageBoxCircInfoService storageBoxCircInfoService;

    @PostMapping(value = "page")
    @ApiOperation(value = "获取分页存储箱使用情况")
    private R<PageVo<StorageBoxCircInfoVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody StorageBoxCircInfoQueryParam storageBoxCircInfoQueryParam) {
        return storageBoxCircInfoService.page(storageBoxCircInfoQueryParam);
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "新增")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody StorageBoxCircInfoParam storageBoxCircInfoParam) {
        return storageBoxCircInfoService.add(storageBoxCircInfoParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody StorageBoxCircInfoParam storageBoxCircInfoParam) {
        return storageBoxCircInfoService.update(storageBoxCircInfoParam);
    }

    @PostMapping(value = "page/for/bind")
    @ApiOperation(value = "获取分页存储箱上架")
    private R<PageVo<StorageBoxCircInfoVo>> pageForBind(@Validated({PageGroup.class, Default.class}) @RequestBody StorageBoxCircInfoQueryParam storageBoxCircInfoQueryParam) {
        return storageBoxCircInfoService.pageForBind(storageBoxCircInfoQueryParam);
    }

    @PostMapping(value = "get")
    @ApiOperation(value = "获取存储箱详情")
    private R<StorageBoxCircInfoVo> get(@Validated @RequestBody IdParam idParam) {
        return storageBoxCircInfoService.get(idParam);
    }

    @PostMapping(value = "getByLocationId")
    @ApiOperation(value = "依据locationId获取当前 库位-箱子 详情")
    private R<StorageBoxCircInfoVo> getByLocationId(@Validated @RequestBody IdParam idParam) {
        return storageBoxCircInfoService.getByLocationId(idParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除当前库存存储箱信息")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return storageBoxCircInfoService.delete(idParam);
    }


}
